﻿// C:\Users\Jorge\Documents\Visual Studio 2010\Projects\C#
//   \LIB\SignalGenLib\SignalParameters.cs
//
// Class to specify the parameters of a digitally-generated signal.
//
// Programmer:  Jorge L. Orejel
//
// Last update: 02/28/2022 

using System;

namespace SignalGenLib
{
   /// <summary>Class to encapsulate the parameters of a digital signal. 
   /// </summary>
   public class SignalParameters
   {
      public double amplitude, offset,   // Signal amplitude and DC offset in volts.
                    frequency,           // Signal frequency in Hertz.
                    period,              // Signal period in seconds.
                    halfPeriod,          // Half of the signal period.
                    samplingFrequency,   // Frequency (in Hertz) for signal generation.
                    frequencyResolution, // Spacing (in Hertz) between adjacent signal values.
                    timeStep;            // Spacing (in seconds) between two adjacent time points.

      public int samplingFactor,         // Factor to multiply by the signal frequency.
                 nSamples;               // Number of signal "samples" to be generated.

      /// <summary>Create an instance of signal parameters.
      /// </summary>
      /// <param name="_amplitude">Amplitude of the signal in volts.</param>
      /// <param name="_frequency">Frequency of the signal in hertz (cycles/second).</param>
      /// <param name="_offset">DC offset (in volts) to be added to the amplitude.</param>
      /// <param name="_nSamples">Number of "samples" to be generated for the signal.</param>
      /// <param name="_samplingFactor">Factor to multiply by {_frequency} for signal-processing.
      /// </param>
      public SignalParameters( double _amplitude, double _frequency,                // Mandatory.
                               double _offset, int _nSamples, int _samplingFactor ) // Optional.
      {
         double one = (double)1.0;

         amplitude =_amplitude;
         frequency = _frequency;
         samplingFactor = _samplingFactor;
         nSamples = _nSamples;
         offset = _offset;

         period = one / frequency;
         halfPeriod = period / (double)2.0;
         samplingFrequency = (double)samplingFactor * frequency;
         frequencyResolution = samplingFrequency / (double)nSamples;

         timeStep = one / samplingFrequency;
      }
   }// SignalParameters (class)
}// SignalGenLib (namespace)
